import {Entity, Column, PrimaryGeneratedColumn, DeleteDateColumn} from 'typeorm';
import {ObjectType, Field} from '@nestjs/graphql';
import {SharedEntity} from "../../../shared/entities/shared.entity"

@ObjectType()
@Entity('account')
export class AccountEntity extends SharedEntity {
    @PrimaryGeneratedColumn({
        type: 'int',
        name: 'id',
    })
    @Field()
    id: number;

    @Column({
        type: 'varchar',
        length: 50,
        name: 'username',
        comment: '用户名',
    })
    @Field(type => String!, { nullable: false, description: '账号名称' })
    username: string;

    @Column({
        type: 'varchar',
        length: 100,
        name: 'password',
        comment: '密码',
    })
    @Field(type => String!, { nullable: false, description: '账号密码' })
    password: string;
    @Column({
        type: 'timestamp',
        name: 'created_at',
        comment: '创建时间',
    })
    createdAt: Date;

    @Column({
        type: 'timestamp',
        name: 'updated_at',
        comment: '更新时间',
    })
    updatedAt: Date;
    @DeleteDateColumn({
        type: 'timestamp',
        name: 'deleted_at',
        comment: '软删除时间',
        nullable: false,
    })
    deletedAt: Date;


    @Field(type => String!, {nullable: true, description: '登录token'})
    token: string;
}
